<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>后台管理-教师管理</title>

    <!-- 使用 Thymeleaf 引入 head.jsp -->
    <th:block th:insert="~{/head :: head}"></th:block>

    <script type="text/javascript">
        function checkAll(obj){
            // 获取复选框对象
            var boxs = document.getElementsByName("ids");
            for(var i = 0; i < boxs.length; i++){
                // 循环设置第 i 个复选框被选中
                boxs[i].checked = obj.checked;
            }
        }
    </script>
</head>
<body>
<div th:insert="~{header::header}"></div>
<div id="main">
    <!-- Start: Sidebar -->
    <div th:insert="~{admin/left::aside}"></div>

    <!-- Start: Content -->
    <section id="content">
        <div id="topbar" class="affix">
            <ol class="breadcrumb">
                <li><a th:href="@{/admin/admin}"><span class="glyphicon glyphicon-home"></span></a></li>
                <li class="active">教师管理</li>
            </ol>
        </div>
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="panel">
                        <div class="panel-heading">
                            <div class="panel-title">教师列表</div>
                            <a th:href="@{/admin/teacher_add}" class="btn btn-info btn-gradient pull-right"><span class="glyphicons glyphicon-plus"></span> 添加教师</a>
                        </div>
                        <form th:action="@{/admin/deleteTeachers}" method="post">
                            <div class="panel-body">
                                <table class="table table-striped table-bordered table-hover dataTable">
                                    <tr class="active">
                                        <th class="text-center">
                                            <input class="btn btn-gray btn-sm" id="selectAll" type="checkbox" onclick="checkAll(this)" />全选
                                        </th>
                                        <th>序号</th>
                                        <th>教师ID</th>
                                        <th>教师名称</th>
                                        <th>职称</th>
                                        <th>用户ID</th>
                                        <th>操作</th>
                                    </tr>

                                    <!-- Thymeleaf 循环替代 c:forEach -->
                                    <tr th:each="m, s : ${teachers}">
                                        <td class="text-center">
                                            <input type="checkbox" name="ids" class="cbox" th:value="${m.teacherId}" />
                                        </td>
                                        <td th:text="${s.index + 1}"></td>
                                        <td><a th:href="@{/admin/findTeacherById/{teacherId}(teacherId=${m.teacherId})}" th:text="${m.teacherId}"></a></td>
                                        <td th:text="${m.name}"></td>
                                        <td th:text="${m.title}"></td>
                                        <td th:text="${m.userId}"></td>

                                        <td>
                                            <div class="btn-group">
                                                <a th:href="@{/admin/findTeacherById(teacherId=${m.teacherId})}">修改</a>
                                                <a th:href="@{/admin/deleteTeacher(teacherId=${m.teacherId})}">删除</a>
                                            </div>
                                        </td>
                                    </tr>
                                </table>

                                <div class="pull-left">
                                    <button type="submit" class="btn btn-default btn-gradient pull-right delall">
                                        删除
                                    </button>
                                </div>
                            </div>


                        </form>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- End: Content -->
</div>
</body>
</html>